<template>
  <div class="order-logistics">
    <p>
      <template v-if="logistics.list">
        <span>{{logistics.list[0].time}}</span>
        <span>{{logistics.list[0].text}}</span>
      </template>
    </p>
    <a href="javascript:;" @click="$refs.orderLogisticsDialog.open()">查看物流</a>
    <order-logistics-dialog ref="orderLogisticsDialog" :logistics="logistics"></order-logistics-dialog>
  </div>
</template>

<script>
import OrderLogisticsDialog from './order-logistics-dialog'
export default {
  name: 'order-logistics',
  components: { OrderLogisticsDialog },
  props: {
    order: {
      type: Object,
      default: () => {}
    }
  },
  data () {
    return {
      logistics: {}
    }
  },
  created () {
    this.findLogistics(this.order.id)
  },
  methods: {
    // 查看物流
    async findLogistics (id) {
      const { data } = await this.$http.get(`member/order/${id}/logistics`)
      this.logistics = data.result
    }
  }
}
</script>

<style scoped lang='less'>
.order-logistics {
  height: 48px;
  margin: 25px 30px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background-color: #f5f5f5;
  > p {
    flex: 1;
    span {
      &:first-child {
        color: #666;
        margin-right: 30px;
      }
    }
  }
  > a {
    color: @xtxColor;
    text-align: center;
    margin-right: 22px;
  }
}
</style>
